<?php
class SucculentWaterAction extends SzAbstractAction
{
    protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_ARRAY,
        SzAbstractAction::TYPE_INT,
    );

    /**
     * 种植浇水
     * @param $userId
     * @param $pos
     * @param $reqTime
     * @return SzResponse
     * @throws SzException
     */
    public function execute($userId, $pos, $reqTime)
    {
        GameService::get()->validateMultiRequestTimeDelta($userId, $reqTime);
        $returnArr = array();
        foreach ($pos as $position){
            $plant = SucculentService::get()->water($userId, $position, $reqTime);
            if (empty($plant)){
                continue;
            }
            else{
                if (!isset($returnArr[$position])){
                    $returnArr[$position] = array(
                        'plant' => $plant,
                    );
                }
            }
        }

        return $this->buildResponse($returnArr);
    }
}